<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file= "../header.jsp" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加数据库配置信息</title>
<link href="/css/becom.css" rel="stylesheet" type="text/css"/>

<script type="text/javascript">
$(document).ready(function(){
    $("#genCode").click(function(){
    	$.post("/generate/table.do?tableId=${bean.id}",{},function(result){
    	   alert(result.msg);
    	  });
	 return false;
	});
});
</script>
</head>
<body>
	<p align="center" class="title">Bean配置信息   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span>(<a href="/generate/table.do?tableId=${bean.id}" id="genCode" style="font-weight: bolder;">genCode</a> )</span> 
	</p>
    <table width="100%">
       <tr>
           <td width="50%">tableName</td>
           <td>${bean.tableName }</td>
       </tr>
       
       <tr>
           <td>beanName</td>
           <td>${bean.beanName }</td>
       </tr>
       
       <tr >
           <td>daoName</td>
           <td>${bean.daoName }</td>
       </tr>
       
       <tr >
           <td>serviceName</td>
           <td>${bean.serviceName }</td>
       </tr>
    </table>
    
    
	<p align="center" class="title" >Bean字段配置信息</p>
    <c:choose>
	    <c:when test="${fn:length(bean.columnList) > 0 }">
		    <table width="100%">
		           <tr>
			         <td width="10%">columnName</td>
			         <td width="10%">propertyName</td>
			         <td width="10%">valueType</td>
			         <td width="50%">enumConfig</td>
			         <td width="10%" >operate</td>
			       </tr>
		        <c:forEach items="${bean.columnList}" var="item">
			       <tr>
			       <td>${item.columnName}</td>
			       <td>${item.propertyName}</td>
			       <td>${item.valueType.javaName}</td>
			       <td>
			          ${item.enumFlagStr}  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			          ${item.enumTypeName} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			          ${item.patternValue}
			       </td>
		           <td>
		             <a href="/field/pUpdate.do?columnId=${item.id}">update</a>
		           </td>
			       </tr>
		       </c:forEach>
		    </table>
	    </c:when>
	    <c:otherwise>
          <form action="/field/add.do" method="post">
	       <table width="100%">
			       <tr>
			         <td width="10%">columnName</td>
			         <td width="10%">propertyName</td>
			         <td width="10%">valueType</td>
			         <td width="50%">enumConfig</td>
			         <td width="10%" >operate</td>
			       </tr>
			       
			       <c:forEach items="${tableModel.columnList }" var="item" varStatus="status">
			          <tr>
				           <td>${item.columnName }</td>
				           <td>
				             <input value="${item.wrappedColumnName }" name="${item.columnName }_fieldName" id="${item.columnName }">
				           </td>
				           <td>
				             ${item.clzStr }
				           </td>
				           
				           <td>
				                <c:choose>
				                   <c:when test="${item.clzStr=='Integer' }">
				                      isEnum: 
				                      <select name="${item.columnName }_isEnum" id="${item.columnName }_isEnum">
				                        <option value="0">false</option>
				                        <option value="1">true</option>
				                      </select>
				                      
				                      enumTypeName:
				                      <input type="text" name="${item.columnName }_enumName" id="${item.columnName }_enumName"/>
				                      
				                      enumPatternValue:
				                      <input type="text" name="${item.columnName }_enumPattern" id="${item.columnName }_enumPattern"/>
				                      
				                   </c:when>
				                   <c:otherwise>
				                      &nbsp;X
				                   </c:otherwise>
				                </c:choose>
				           </td>
				           
				           <c:if test="${status.index == 0 }">
				             <td rowspan="${fn:length(tableModel.columnList) }">
				                <input type="hidden" value="${tableModel.tableMappingBean.id }" name="tableId" id="tableId"/>
				             
				                <input  value="submit" type="submit"/>
				             </td>
				           </c:if>
				       </tr>
			       </c:forEach>
	       </table>
         </form>
	    </c:otherwise>
    </c:choose>
    
    <p align="center" class="title">Bean方法配置信息  </p>
    
     <c:choose>
	    <c:when test="${fn:length(bean.methodList) > 0 }">
		    <table width="100%">
		         <tr>
		            <td>result</td>
		            <td>MethodResultType</td>
		            <td>methodName</td>
		            <td>ParameterCombineType</td>
		            <td>MethodOperateType</td>
		            <td width="60%" align="center">parameters</td>
		         </tr>
		         <c:forEach items="${bean.methodList }" var="item">
		            <tr>
		            <td>
		                <c:forEach items="${item.resultList }" var="column">
		                    ${column.columnMappingBean.propertyName } <br>
		                </c:forEach>
		                <c:forEach items="${item.updateList }" var="column">
		                    ${column.columnMappingBean.propertyName } <br>
		                </c:forEach>
		            </td>
		            <td>${item.methodResultType}</td>
		            <td>${item.functionName}</td>
		            <td>${item.methodParameterType}</td>
		            <td>${item.methodOperateType}</td>
		            <td valign="top">
		              <table width="100%">
		                 <tr>
		                   <td>propertyName</td>
		                   <td>beginParameterName</td>
		                   <td>endParameterName</td>
		                   <td>listFlag</td>
		                 </tr>
		                 <c:forEach items="${item.parameterList }" var="column">
		                    <tr>
		                      <td>${column.columnMappingBean.propertyName }</td>
			                  <td>${column.beginParameterName }</td>
			                  <td>${column.endParameterName }</td>
			                  <td>${column.listFlagStr }</td>
		                    </tr>
		                 </c:forEach>
		               </table>
		            </td>
		         </tr>
		         </c:forEach>
		    </table>
	    </c:when>
	    <c:otherwise>
	       <table width="100%" align="center">
	          <tr>
	          <td width="100%" align="center">无数据!</td>
	          </tr>
	       </table>
	    </c:otherwise>
	 </c:choose>
     <p align="center"> <a href="/method/pAdd.do?tableId=${bean.id }">addMethod>>></a></p>
    
</body>
</html>